//
// Created by mac on 1/27/22.
//
#include <vector>
using namespace std;
vector<int> addToArrayForm(vector<int>& num, int k) {
    vector<int> res;
    int i = num.size()-1;
    int carry = 0;
    while (i>=0 || k!=0){
        int x = i>=0?num[i]:0;
        int y = k!=0?k%10:0;
        int sum = x+y+carry;
        carry = sum/10;
        res.push_back(sum%10);
        i--;
        k=k/10;
    }
    if (carry) res.push_back(carry);
    reverse(res.begin(), res.end());
    return res;

}